package _3ChapterThree._8ChangeBidirectionalAssociationToUnidirectional.step1;

public class Order {
    private Customer _customer;

    private double grossPrice = 0;

    public double getGrossPrice() {
        return grossPrice;
    }

    public void setGrossPrice(double grossPrice) {
        this.grossPrice = grossPrice;
    }

    public Customer get_customer() {
        return _customer;
    }

    public void set_customer(Customer arg) {
        if (_customer != null) {
            _customer.friendOrders().remove(this);
        }
        _customer = arg;
        if (_customer != null) {
            _customer.addOrder(this);
        }
    }

    public double getDiscountedPrice() {
        return getGrossPrice() * (1 - _customer.getDiscount());
    }
}
